inspector: Add a Label column
authorMatthias Clasen <mclasen@redhat.com>
Fri, 9 May 2014 01:15:09 +0000 (21:15 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 11 May 2014 02:04:27 +0000 (22:04 -0400)
Move the UI strings over to that column, and use the buildable
ID for the name column, where available.

modules/inspector/widget-tree.c
modules/inspector/widget-tree.ui

index df81096907a235e8a45c4f146ea687c03d59a025..165339a2a287d7bf22e34beba000fc24c19da638 100644 (file)
@@ -31,6 +31,7 @@ enum
   OBJECT,
   OBJECT_TYPE,
   OBJECT_NAME,
+  OBJECT_LABEL,
   OBJECT_ADDRESS,
   SENSITIVE
 };
@@ -75,7 +76,7 @@ object_data_free (gpointer data)
 
   gtk_tree_iter_free (od->iter);
 
-  if (od->map_handler)
+  if (g_signal_handler_is_connected (od->object, od->map_handler))
     {
       g_signal_handler_disconnect (od->object, od->map_handler);
       g_signal_handler_disconnect (od->object, od->unmap_handler);
@@ -184,7 +185,9 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
   gchar *address;
   gboolean mapped;
   ObjectData *od;
+  const gchar *label;
 
+  label = NULL;
   mapped = FALSE;
 
   if (GTK_IS_WIDGET (object))
@@ -197,16 +200,24 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
 
   if (name == NULL || g_strcmp0 (name, class_name) == 0)
     {
-      if (GTK_IS_LABEL (object))
-        name = gtk_label_get_text (GTK_LABEL (object));
-      else if (GTK_IS_BUTTON (object))
-        name = gtk_button_get_label (GTK_BUTTON (object));
-      else if (GTK_IS_WINDOW (object))
-        name = gtk_window_get_title (GTK_WINDOW (object));
-      else
-        name = "";
+      if (GTK_IS_BUILDABLE (object))
+        name = gtk_buildable_get_name (GTK_BUILDABLE (object));
     }
 
+  if (name == NULL)
+    name = "";
+
+  if (GTK_IS_LABEL (object))
+    label = gtk_label_get_text (GTK_LABEL (object));
+  else if (GTK_IS_BUTTON (object))
+    label = gtk_button_get_label (GTK_BUTTON (object));
+  else if (GTK_IS_WINDOW (object))
+    label = gtk_window_get_title (GTK_WINDOW (object));
+  else if (GTK_IS_TREE_VIEW_COLUMN (object))
+    label = gtk_tree_view_column_get_title (GTK_TREE_VIEW_COLUMN (object));
+  else
+    label = "";
+
   address = g_strdup_printf ("%p", object);
 
   gtk_tree_store_append (wt->priv->model, &iter, parent_iter);
@@ -214,6 +225,7 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
                       OBJECT, object,
                       OBJECT_TYPE, class_name,
                       OBJECT_NAME, name,
+                      OBJECT_LABEL, label,
                       OBJECT_ADDRESS, address,
                       SENSITIVE, !GTK_IS_WIDGET (object) || mapped,
                       -1);
index 5b94e00de358aaa81cf0c8036e9678dcbaa6d58f..74518847a9ddc7c38d16c5ddb5b453085a23dfe9 100644 (file)
@@ -6,6 +6,7 @@
       <column type="gchararray"/>
       <column type="gchararray"/>
       <column type="gchararray"/>
+      <column type="gchararray"/>
       <column type="gboolean"/>
     </columns>
   </object>
@@ -28,7 +29,7 @@
           </object>
           <attributes>
             <attribute name="text">1</attribute>
-            <attribute name="sensitive">4</attribute>
+            <attribute name="sensitive">5</attribute>
           </attributes>
         </child>
       </object>
           </object>
           <attributes>
             <attribute name="text">2</attribute>
-            <attribute name="sensitive">4</attribute>
+            <attribute name="sensitive">5</attribute>
+          </attributes>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkTreeViewColumn">
+        <property name="title" translatable="yes">Label</property>
+        <property name="resizable">True</property>
+        <child>
+          <object class="GtkCellRendererText">
+            <property name="scale">0.8</property>
+          </object>
+          <attributes>
+            <attribute name="text">3</attribute>
+            <attribute name="sensitive">5</attribute>
           </attributes>
         </child>
       </object>
@@ -58,8 +74,8 @@
             <property name="family">monospace</property>
           </object>
           <attributes>
-            <attribute name="text">3</attribute>
-            <attribute name="sensitive">4</attribute>
+            <attribute name="text">4</attribute>
+            <attribute name="sensitive">5</attribute>
           </attributes>
         </child>
       </object>